#coding=utf-8
import sys
sys.path.insert(0, './lib')

import logging
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext import webapp

import models, job, service

class Status(webapp.RequestHandler):
    def get(self):
        n = models.get_stock_count()
        self.response.out.write("The number of stock in db: %i"%n)
    
def main():
  application = webapp.WSGIApplication([
                                        ('/init', job.Init),
                                        ('/get_codes', job.CodeGetter),
                                        ('/update_job', job.Updater),
                                        ('/new_stock', job.NewStock),
                                        ('/update_ts', job.TsUpdater),
                                        
                                        ('/delete', job.Deleter),
                                        
                                        ('/stock', service.Stock),
                                        ('/ts', service.TS),
                                        ('/today', service.Today),
                                        
                                        ('/status', Status)
                                       ],
                                       
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
  main()
